package com.ruoyi.vedio_room.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.vedio_room.domain.LiveRoom;
import com.ruoyi.vedio_room.service.ILiveRoomService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 直播间管理Controller
 * 
 * @author 申明义
 * @date 2024-10-28
 */
@RestController
@RequestMapping("/vedio_room/vedio_room")
public class LiveRoomController extends BaseController
{
    @Autowired
    private ILiveRoomService liveRoomService;

    /**
     * 查询直播间管理列表
     */
    @PreAuthorize("@ss.hasPermi('vedio_room:vedio_room:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveRoom liveRoom)
    {
        startPage();
        List<LiveRoom> list = liveRoomService.selectLiveRoomList(liveRoom);
        return getDataTable(list);
    }

    /**
     * 导出直播间管理列表
     */
    @PreAuthorize("@ss.hasPermi('vedio_room:vedio_room:export')")
    @Log(title = "直播间管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LiveRoom liveRoom)
    {
        List<LiveRoom> list = liveRoomService.selectLiveRoomList(liveRoom);
        ExcelUtil<LiveRoom> util = new ExcelUtil<LiveRoom>(LiveRoom.class);
        util.exportExcel(response, list, "直播间管理数据");
    }

    /**
     * 获取直播间管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('vedio_room:vedio_room:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(liveRoomService.selectLiveRoomById(id));
    }

    /**
     * 新增直播间管理
     */
    @PreAuthorize("@ss.hasPermi('vedio_room:vedio_room:add')")
    @Log(title = "直播间管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveRoom liveRoom)
    {
        return toAjax(liveRoomService.insertLiveRoom(liveRoom));
    }

    /**
     * 修改直播间管理
     */
    @PreAuthorize("@ss.hasPermi('vedio_room:vedio_room:edit')")
    @Log(title = "直播间管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveRoom liveRoom)
    {
        return toAjax(liveRoomService.updateLiveRoom(liveRoom));
    }

    /**
     * 删除直播间管理
     */
    @PreAuthorize("@ss.hasPermi('vedio_room:vedio_room:remove')")
    @Log(title = "直播间管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(liveRoomService.deleteLiveRoomByIds(ids));
    }
}
